package com.yan.design.two.structure.s6;

/**
 * 6. 享元模式
 *      测试
 * @author shengren.yan
 * @create 2022-08-01
 */
public class testRun {

    public static void main(String[] args) {

        WebSiteFactory factory = new WebSiteFactory();

        // 内部状态
        WebSite w1 = factory.getWebSiteCategory("新闻");
        w1.use();

        WebSite w2 = factory.getWebSiteCategory("体育");
        w2.use();

        WebSite w3 = factory.getWebSiteCategory("体育");
        w3.use();

        int webSiteCount = factory.getWebSiteCount();
        System.out.println("网总共个数" + webSiteCount); // 2个

        System.out.println("----------------");
        // 外部状态
        WebSite w4 = factory.getWebSiteCategory("体育");
        w4.use(new User("A"));

        WebSite w5 = factory.getWebSiteCategory("娱乐");
        w5.use(new User("B"));

        WebSite w6 = factory.getWebSiteCategory("娱乐");
        w6.use(new User("D"));

        int wa2 = factory.getWebSiteCount();
        System.out.println("网总共个数" + wa2); // 2个


    }

}
